import { createStore } from 'vuex'

const store = createStore({
    state: {
        orderNumber:"",
        tel: "",                    //电话号码
        giftName: "",               //礼物名称
        backgroundImage: "",        //背景图片
        audio: "",                  //录音
        video:"",                   //上传的视频
        VV: "",                     //播放次数
        expiresTime: "",            //失效时间
    },
    mutations:{
        updateOrderNumber(state,payload){
            state.orderNumber=payload
        },
        updateTel(state,payload){
            state.tel=payload
        },
        updateGiftName(state,payload){
            state.giftName=payload
        },
        updateBackgroundImage(state,payload){
            state.backgroundImage=payload
        },
        updateAudio(state,payload){
            state.audio=payload
        },
        updateVV(state,payload){
            state.VV=payload
        },
        updateExpiresTime(state,payload){
            state.expiresTime=payload
        },
        updateVideo(state, payload) {
            state.video = payload;
        }
        
    },
    actions: {
        async saveAudio({ commit }, audioBlob) {
          const audioUrl = URL.createObjectURL(audioBlob);
          commit("setAudioUrl", audioUrl);
        },
        updateBackgroundImage({commit}, payload){
            commit('updateBackgroundImage', payload)
        }
      },
})

export default store